package kr.co.m2soft.intern;

import java.nio.ByteBuffer;

public class UInt {
	private long value = 0;
	private final long MAX_VALUE = 4294967295L;
	
	public UInt(long value_) {
		this.value = value_;
	}
	
	public void setValue(long value_) {
		this.value = value_ > MAX_VALUE ? value_ - MAX_VALUE - 1 : value_;
	}
	
	public long getValue() {
		return this.value;
	}
	
	public byte[] getBytes() {
		byte[] bytes = new byte[4];
		ByteBuffer buffer = ByteBuffer.allocate(Long.BYTES);
	    buffer.putLong(this.value);
	    
		bytes[0] = buffer.array()[4];
		bytes[1] = buffer.array()[5];
		bytes[2] = buffer.array()[6];
		bytes[3] = buffer.array()[7];
		
		return bytes;
	}
}
